C
C *** LAST REVISED ON 21-JUL-1987 07:50:52.35
C *** SOURCE FILE: [DL.GRAPHICS.LONGLIB]BITCURSOR.FOR
C
C ***********************************************************************
C
C	COMPLETELY FORTRAN 77 COMPABIBLE WITH THE EXCEPTION OF
C		1. ROUTINE NAME LENGTH
C		2. LEADING TABS (^I)
C
C	MACHINE DEPENDENT NOTES:
C		1. USES CHAR() TO CONVERT AN INTEGER TO ITS ASCII EQUIVALENT
C		   CHARACTER IN A DATA STATEMENT.
C		2. USES ICHAR() TO CONVERT A CHARACTER VARIABLE TO AN
C		   INTEGER WITH ITS ASCII EQUIVALENT VALUE.
C
C ***********************************************************************
C
	SUBROUTINE BITCURSOR(X,Y,IKEY,ARESX,ARESY)
C
C	CREATED BY D. LONG    MAR, 1985		AT JPL
C
C	THIS ROUTINE MOVES A CROSS-HAIR "CURSOR" ON THE GRAPHICS
C	DEVICE USING A RETRO-GRAPHICS EQUIPPED VT100 (VT125) WITH BIT PAD ONE
C	GRAPHICS INPUT DEVICE (ASSUMES ASCII INPUT)
C
C	X,Y	RETURNED CURSOR POSITION RELATIVE TO INITIALIZED GRAPHICS PACKAGE
C	IKEY	KEY PRESSED ON BITPAD CURSOR
C		KEY PRESSED - RETURNED CODE
C			(Z) = 0
C			(1) = 1
C			(2) = 2
C			(3) = 3
C	ARESX,ARESY RESOLUTION OF SCREEN DEVICE (RETURNED)
C
	COMMON/VT100/IVT100,IVM(32),VRE(2),VOX,VOY,VSF,NIVM,VANG,ITERM,
     $		VVP(4),MV,MVW,IVCOL,IXLIM,IYLIM,IYREV,VLIM(2)
C
	CHARACTER*1 S(6)
	CHARACTER*(*) PROMPT
	PARAMETER (PROMPT=CHAR(29)//CHAR(26)//CHAR(27))
C
	IF (IVT100.LE.0) RETURN	
C
C	GET BIT PAD CURSOR LOCATION
C	READ GRAPHICS INPUT (BIT PAD)
C
	WRITE (*,1) PROMPT
 1	FORMAT(X,A3,$)
	READ(*,2) S
 2	FORMAT(6A1)
C
C	DETERMINE WHICH BIT PAD KEY WAS PRESSED
C
C	RETURN CODES: Z=17, 1=18, 2=20, 3=24
C
	IKEY=ICHAR(S(1))-48
	IKEY=IKEY-17
	IF (IKEY.EQ.3) IKEY=2
	IF (IKEY.EQ.7) IKEY=3
C
C	CONVERT GRAPHICS INPUT STRING TO TEK 4010 COORDINATES
C
	IXH=ICHAR(S(2))-32
	IXL=ICHAR(S(3))-32
	IX=IXL+IXH*32
	IYH=ICHAR(S(4))-32
	IYL=ICHAR(S(5))-32
	IY=IYL+IYH*32
C
C	SET UP CONVERSION CONSTANTS
C
	RESX=VRE(1)
	RESY=VRE(2)
	ARESX=RESX/VSF
	ARESY=RESY/VSF
	ANG=VANG
	COSA=COS(ANG*0.0174532)
	SINA=SIN(ANG*0.0174532)
C
C	COMPUTE LOCATION OF CURSOR RELATIVE TO PLOT PACKAGE
C
C	IY=IUSE(2)-IY
C
	X=((FLOAT(IX)*RESX-VOX)*COSA+(FLOAT(IY)*RESY-VOY)*SINA)/VSF
	Y=(-(FLOAT(IX)*RESX-VOX)*SINA+(FLOAT(IY)*RESY-VOY)*COSA)/VSF
C
	RETURN
	END
